package com.sunshine.spring.beans.annotation;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;

/**
 * @Author: WeiHong
 * @Date: 2017/3/20 10:10
 */
public class Customer {

    /**
     * 1.required=false 如果Spring不能找到一个匹配的Bean，person属性将不设定
     * 2.@Qualifier() 自动装配一个特定的 bean (在xml中，有定义了两个Person,spring不知道要加载哪个Person Bean,会报错)
     */
    @Autowired(required = false)
    @Qualifier("person2")
    private Person person;

    private String action;

    private String type;

    public Person getPerson() {
        return person;
    }

    public void setPerson(Person person) {
        this.person = person;
    }

    public String getAction() {
        return action;
    }

    public void setAction(String action) {
        this.action = action;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    @Override
    public String toString() {
        return "Customer{" +
                "person=" + person +
                ", action='" + action + '\'' +
                ", type='" + type + '\'' +
                '}';
    }
}
